package jm.demo.proxy.cglib.wrapper;

import org.springframework.beans.factory.FactoryBean;

public class RoundRobinFactory<T> implements FactoryBean<T> {
	
	private T[] pool;
	private int counter = 0;

	public T[] getPool() {
		return pool;
	}

	public void setPool(T[] pool) {
		this.pool = pool;
	}

	@Override
	public T getObject() throws Exception {
		return pool[counter++%pool.length];
	}

	@Override
	public Class<?> getObjectType() {
		return pool[0].getClass();
	}

	@Override
	public boolean isSingleton() {
		return true;
	}

	
}
